﻿using LitJson;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;


public class Item2
{
    public int id;
    public int num;

    public Item2() { }

    public Item2(int id, int num)
    {
        this.id = id;
        this.num = num;
    }
}

public class PlayerInfo2
{
    public string name;
    public int atk;
    public int def;
    public float moveSpeed;
    public double roundSpeed;
    public Item2 weapon;
    public List<int> listInt;
    public List<Item2> itemList;

    public Dictionary<string, Item2> itemDic2;
    private int privateI = 1;
    protected int protectedI = 2;

    public PlayerInfo2() { }

}

public class Info
{
    public int id;
    public int type;
    public double cd;
    public string ids;
    public int delay;
}

public class Test2 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        PlayerInfo2 info1 = new PlayerInfo2();
        info1.name = "lik";
        info1.atk = 1;
        info1.def = 5561;
        info1.moveSpeed = 6;
        info1.roundSpeed = 8.5;
        info1.weapon = new Item2(15, 5);
        info1.listInt = new List<int>() { 45646, 464568, 34, 3535 };
        info1.itemList = new List<Item2>() { new Item2(1, 12), new Item2(2, 152) };
        
        info1.itemDic2 = new Dictionary<string, Item2>() { { "232", new Item2(14, 233) }, { "65", new Item2(144, 233) } };

        //print(Application.persistentDataPath);

        //string path = Application.persistentDataPath + "/LitT.json";
        //File.WriteAllText(path, JsonMapper.ToJson(info1));

        //string text = File.ReadAllText(path);
        //PlayerInfo2 info2 = JsonMapper.ToObject<PlayerInfo2>(text);

        //print("t");

        ////读取数据集合
        //path = Application.persistentDataPath + "/t.json";
        //Info[] i = JsonMapper.ToObject<Info[]>(File.ReadAllText(path));

        JsonManager.Instance.SaveData(info1, "Hello");

        PlayerInfo2 info2 = JsonManager.Instance.LoadData<PlayerInfo2>("Hello");


        print("t");
    }

    
}
